package com.itheima.api.treemap.demo02;

public class Student implements Comparable<Student> {

    private String name ;

    private int age ;

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    @Override
    public int compareTo(Student o) {

        // 按照学生的年龄进行排序，如果年龄相同，比较姓名
        int result1 = this.age - o.age ;
        int result2 = result1 == 0 ? this.name.compareTo(o.name) : result1 ;

        // 返回
        return result2;
    }
}
